package czk.concrent.synControl.practice5;

import java.util.concurrent.locks.LockSupport;

/**
 * @author chenzhangkun
 * @ClassName LockSupportSyncPrint
 * @description: TODO
 * @date 2025年02月11日
 */
public class LockSupportSyncPrint {
	static Thread t1;
	static Thread t2;
	static Thread t3;
	public static void main(String[] args) {
		UnPart unPart=new UnPart(5);
		t1=new Thread(()->unPart.print("A",t2),"t1");
		t2=new Thread(()->unPart.print("B",t3),"t2");
		t3=new Thread(()->unPart.print("C",t1),"t3");
		t1.start();
		t2.start();
		t3.start();
		LockSupport.unpark(t1);
	}
	public static class UnPart {
		private Integer loopNum;


		public UnPart( Integer loopNum) {
			this.loopNum = loopNum;
		}

		public  void print(String content, Thread t){
			for (int i = 0; i < loopNum; i++) {
				LockSupport.park();
				System.out.println(Thread.currentThread().getName()+"===="+content);
				LockSupport.unpark(t);
			}
		}


	}
}
